package com.comsumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ConsumerConfig {

    //1.声明注册fanout模式的交换机
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("direct.exchange", true, false);
    }

    //2.声明队列
    @Bean
    public Queue smsQueue() {
        return new Queue("direct.queue", true);
    }

    //3.完成绑定关系（队列与交换机完成绑定关系）
    @Bean
    public Binding smsBind() {
        return BindingBuilder.bind(smsQueue()).to(fanoutExchange());
    }

}
